
from Move_img import *

class D_Wall(Move_img):
    def __init__(self, pos_x, pos_y,pox_width,pox_height,dire,speed,visible,check,f_x=0):
        self.image = pygame.Surface((pox_width,pox_height))
        self.image.fill((105, 50, 10))
        super().__init__(self.image,pos_x,pos_y,visible)
        self.visible = visible
        self.check = check
        self.f_x = f_x
        self.dire = dire  # 移动方向
        self.speed_ = speed
        self.speed = 0  # 移动速度
        self.active = False  # 是否激活移动

    def activate(self):
        self.active = True

    def update(self, window):
        if self.active:
            self.img_move(self.dire, self.speed_)
            if not self.alive and self.visible:
                self.kill()

    def wall_move(self,dire='x',speed=-6):
        self.dire = dire
        self.speed = speed
        if not self.visible and not self.alive:
            if self.dire=='x':
                self.rect.x += self.speed
                if self.speed<0 and self.rect.x <= self.f_x:
                    self.kill()
                elif self.speed>0 and self.rect.x >= self.f_x:
                    self.kill()
            elif self.dire=='y':
                self.rect.y += self.speed
                if self.speed < 0 and self.rect.y <= self.f_x:
                    self.kill()
                elif self.speed > 0 and self.rect.y >= self.f_x:
                    self.kill()

